package com.bishe.controller;

import com.bishe.controller.utils.R;
import com.bishe.domain.Bulletin;
import com.bishe.sevice.IBulletinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//@CrossOrigin
@RestController
@RequestMapping("/bulletin")
public class BulletinController {

    @Autowired
    private IBulletinService iBulletinService;

    @GetMapping
    public R getAll(){
        return new R(true,iBulletinService.list());
    }

    @PostMapping
    public R save(@RequestBody Bulletin bulletin){
        return new R(iBulletinService.save(bulletin));
    }

    @PutMapping
    public R update(@RequestBody Bulletin bulletin){
        return new R(iBulletinService.modify(bulletin));
    }

    @DeleteMapping("{id}")
    public R delete(@PathVariable Integer id){
        return new R(iBulletinService.delete(id));
    }

    @GetMapping("{id}")
    public R getById(@PathVariable Integer id) {
        return new R(true, iBulletinService.getById(id));
    }

}
